<extend name="Index:base" />
<block name="content">
    <div class="main-content">
        <div class="breadcrumbs" id="breadcrumbs">
            <!-- 面包屑导航 -->
            <ul class="breadcrumb">
                <li>
                    <i class="icon-home home-icon"></i>
                    <a href="{:U('Admin/Index/index')}">首页</a>
                </li>
                <li class="active">{$title}</li>
            </ul>
        </div>

        <div class="page-content">
            <!-- 页面导航 -->
            <div class="page-header">
                <h1>
                    {$title}
                    <small>
                        <i class="icon-double-angle-right"></i>
                         查看
                    </small>
                </h1>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <form class="form-horizontal" role="form">
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right"> 原密码 </label>
                            <div class="col-sm-10">
                                <input class="col-xs-10 col-sm-5" type="password" placeholder="请填写原密码" name="oldpwd">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right"> 新密码 </label>
                            <div class="col-sm-10">
                                <input class="col-xs-10 col-sm-5" type="password" placeholder="请填写新密码" name="newpwd">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right"> 确认密码 </label>
                            <div class="col-sm-10">
                                <input class="col-xs-10 col-sm-5" type="password" placeholder="请填写确认密码" name="repwd">
                            </div>
                        </div>
                        <div class="clearfix form-actions">
                            <div class="col-md-offset-2 col-md-10">
                                <button id="sub-pwd" class="btn btn-info" type="button">
                                    <i class="icon-ok bigger-110"></i>
                                    修改密码
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- 中间部分结束 -->

    <div id="success-info" class="alert alert-success fade in col-xs-4 hide" style="position:fixed;top:20px;left:35%;z-index:1000;">
        <button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>
        <strong></strong>
    </div>
    <div id="error-info" class="alert alert-danger fade in col-xs-4 hide" style="position:fixed;top:20px;left:35%;z-index:1000;">
        <button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>
        <strong></strong>
    </div>
    <!-- 删除按钮弹出层结束 -->
</block>
<block name="privatejs">
    <script type="text/javascript">
        jQuery(function($) {
            //设置当前页面的菜单高亮显示 开始
            var nownav = "#sidebar a[href*=Profile]";
            var parentattr = $(nownav).parent().parent().attr("class");
            $(nownav).parent().addClass('active');
            if (parentattr == 'submenu') {
                $(nownav).parent().parent().parent().addClass('active open');
            };
            //设置当前页面的菜单高亮显示 结束

            $('#sub-pwd').on('click',function(){
                var oldpwd = $('input[name=oldpwd]').val();
                var newpwd = $('input[name=newpwd]').val();
                var repwd = $('input[name=repwd]').val();
                if (newpwd != repwd) {
                    warningInfo("#error-info","两次密码输入不匹配！");
                    return;
                };

                $.ajax({
                    url:"__APP__/Admin/Profile/updataPwd",
                    type:'post',
                    data:{oldpwd:oldpwd,newpwd:newpwd},
                    success:function(data){
                        if (data == 1) {
                            warningInfo("#success-info","密码修改成功！");
                            location.href="__APP__/Admin/Login/loginOut";
                        }else{
                            warningInfo("#error-info","密码修改失败！");
                        }
                    }
                });
            });

            //信息提示函数
            function warningInfo(id,info){
                $(id).removeClass('hide');
                $(id).fadeOut(0);
                $(id).children().eq(1).html(info);
                $(id).fadeToggle(0).delay(1000).fadeToggle(1000);
            }
        });
    </script>
</block>